SftTree/NET 2.0

RecalcHorizontalExtent Method, SftTree Class

Softel vdm, Inc.

Recalculates the optimal horizontal scrolling extent.

Syntax      SftTree Class (Softelvdm.SftTreeNET)

VB   

Public Sub RecalcHorizontalExtent()

C#   

public void RecalcHorizontalExtent();

C++   

public: void RecalcHorizontalExtent();

Comments

The RecalcHorizontalExtent method recalculates the optimal horizontal scrolling extent.

By default, a tree control does not handle horizontal scrolling, even if the ScrollbarHorizontal property defines scroll bars to be available. To start horizontal scrolling, an application has to use the ColumnClass.MakeOptimal (or Columns.MakeOptimal) first. This calculates the optimal width for each (or all columns). Then RecalcHorizontalExtent or the HorizontalExtent property is used to indicate to the tree control that horizontal scrolling support is desired based on the current column widths.

Once the horizontal scrolling extent has been set, many tree control methods and properties may invalidate the horizontal extent. E.g., adding a new item may invalidate the extent, so it is best to delay using the RecalcHorizontalExtent method until after all items have been added and all properties have been set.

The tree control doesn't automatically update the horizontal extent when items are added or deleted or other methods or properties are used, which may invalidate the horizontal extent. The ColumnClass.MakeOptimal and RecalcHorizontalExtent method have to be used again to recalculate the extent.

Based on the definition of the last column, different algorithms are used to calculate the optimal scrolling extent. Using the Columns.LastOpenended property, the last column can be defined as open-ended. An open-ended last column will display the complete cell contents for the last (or only) displayed column and never truncate any data. A fixed-width last column is defined with a specified width and any data which doesn't fit is truncated.

Open-Ended Last Column (Columns.LastOpenended)

Recalculating the best horizontal scrolling extent can be a costly operation (in terms of elapsed time). When updating a tree control, it is best to delay using the ColumnClass.MakeOptimal (or Columns.MakeOptimal) RecalcHorizontalExtent method as much as possible. It is best done after all items have been added with all their cells and attributes, because most changes to the tree control can invalidate the optimal horizontal scrolling extent calculated.

When calculating the optimal column widths, each item will be analyzed and its length calculated using the item's cell contents.

Fixed-Width Last Column

Recalculating the best horizontal scrolling extent is a very quick operation. The width of all columns and some initial overhead (based on the highest level number found) is calculated to determine the horizontal scrolling extent.


Feedback / comments / error reports for this topic
© 2007 - Softel vdm, Inc. - www.softelvdm.com